<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{block name="title"}金夫人玛瑞莎业务系统{/block}</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="__CSS__/bootstrap.min.css">
    <link rel="stylesheet" href="__CSS__/AdminLTE.min.css">
    <script type="text/javascript" src="__JS__/jquery-2.2.3.min.js"></script>
    <style>
        .wrapper {
            padding: 15px;
        }

        .wrapper::after {
            clear: both;
            display: block;
            content: '';
            margin-bottom: 30px;
        }
        .panel {
            border: none;
        }

        .panel-heading {
            border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
            padding: 15px;
            text-transform: uppercase;
            color: #535351;
            font-size: 16px;
            font-weight: bold;
        }


    </style>
</head>
<body >
<!--body wrapper start-->
<div class="wrapper">
    <div class="row">

        <div class="col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    新增类别
                </header>
                <div class="panel-body">
                    <div class=" form">
                        <form class="cmxform form-horizontal adminex-form" id="commentForm" method="post" action="{:url('add')}">
                            <div class="form-group ">
                                <label  class="control-label col-xs-4">排序</label>
                                <div class="col-xs-5">
                                    <input class="form-control"   name="sid" type="text" required value="100" />
                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="control-label col-xs-4">名称</label>
                                <div class="col-xs-5">
                                    <input class="form-control"  name="name" type="text" required />
                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="control-label col-xs-4">电话</label>
                                <div class="col-xs-5">
                                    <input class="form-control"  name="phone" type="text" required />
                                </div>
                            </div>
                            <div class="form-group ">
                                <label class="control-label col-xs-4" id="address">简介</label>
                                <div class="col-xs-5">
                                     <textarea class="form-control"  name="address"></textarea>
                                </div>
                            </div>
                            <div class="form-group" id="diqu" style="display: none">
                                <label class="control-label col-xs-4">地区：</label>
                                <div class="col-xs-5">
                                    <select class="form-control" name="dq">
                                        <option value="">请选择类别</option>
                                        {volist name="diqu" id="data"}
                                        <option value="{$data.id}"  {eq name="info['dq']" value="$data.id"} selected="selected" {/eq}>{$data.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-4">类别：</label>
                                <div class="col-xs-5">
                                    <select class="form-control" id="sel" name="leibie">
                                        <option value="">请选择类别</option>
                                        {volist name="leibie" id="data" required }
                                             <option value="{$data.id}" {eq name="info['leibie']" value="$data.id"} selected="selected"{/eq}>{$data.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>


                            <!-- 类别ID -->

                            <div class="form-group">
                                <div class="col-lg-offset-2 col-xs-10">
                                    <button class="btn btn-primary text-" id="submit" type="submit" >提交</button>

                                    <button class="btn btn-default" type="button" id="exit">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>
            </section>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
<script>
    $().ready(function () {
        var leibie = $('#sel');
        leibie.change(function () {
            // 课程
            if(leibie.val() == 4){
                $('#address').html('课程简介');
            }else {
                $('#address').html('地址');
            }
            if($(this).val() == 3){
                $("#diqu").show();
            }else{
                $("#diqu").hide();
            }
        });
    });
</script>
<script>
    $('#submit').click(function () {
        $.ajax({
            type: "POST",
            url:  "{:url('add')}",
            data: $('#commentForm').serialize(),
            beforeSend:function(){
                $(this).attr("disabled","false"); //禁止点击
            },
            success: function(info){
                //console.log(info);

                if(info.status==1){
                    layer.msg(info.msg, {icon: 1});
                    setTimeout(function(){
//                        location.href=info.url;
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },3000); //延迟演示
                }else{
                   layer.msg(info.msg, {icon: 5});
                    $('#submit').removeAttr("disabled"); //禁止点击
                }

            }
        });
        return false;
    });
    $('#exit').click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    });
</script>

